#include <iostream>
using namespace std;


int main() {
    int n;
    cin >> n;
    int arr[n];
    int ret = 0;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    int p = arr[0];
    for (int i = 1; i < n; i++)
    {
        ret = max(ret, arr[i] - p);
        p = min(arr[i], p);
    }
    cout << ret;
    return 0;
}